﻿/****** Object:  ForeignKey [FK_Forum_Messages_Forum_Categories]    Script Date: 06/16/2011 13:48:43 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Forum_Messages_Forum_Categories]') AND parent_object_id = OBJECT_ID(N'[dbo].[SocailShare_Forum_Messages]'))
ALTER TABLE [dbo].[SocailShare_Forum_Messages] DROP CONSTRAINT [FK_Forum_Messages_Forum_Categories]

/****** Object:  ForeignKey [FK_SocialShare_Blog_Comments_SocialShare_Blogs]    Script Date: 06/16/2011 13:48:43 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_SocialShare_Blog_Comments_SocialShare_Blogs]') AND parent_object_id = OBJECT_ID(N'[dbo].[SocialShare_Blog_Comments]'))
ALTER TABLE [dbo].[SocialShare_Blog_Comments] DROP CONSTRAINT [FK_SocialShare_Blog_Comments_SocialShare_Blogs]

/****** Object:  Table [dbo].[SocialShare_Blog_Comments]    Script Date: 06/16/2011 13:48:43 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_SocialShare_Blog_Comments_SocialShare_Blogs]') AND parent_object_id = OBJECT_ID(N'[dbo].[SocialShare_Blog_Comments]'))
ALTER TABLE [dbo].[SocialShare_Blog_Comments] DROP CONSTRAINT [FK_SocialShare_Blog_Comments_SocialShare_Blogs]

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[SocialShare_Blog_Comments]') AND type in (N'U'))
DROP TABLE [dbo].[SocialShare_Blog_Comments]

/****** Object:  Table [dbo].[SocailShare_Forum_Messages]    Script Date: 06/16/2011 13:48:43 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Forum_Messages_Forum_Categories]') AND parent_object_id = OBJECT_ID(N'[dbo].[SocailShare_Forum_Messages]'))
ALTER TABLE [dbo].[SocailShare_Forum_Messages] DROP CONSTRAINT [FK_Forum_Messages_Forum_Categories]

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[SocailShare_Forum_Messages]') AND type in (N'U'))
DROP TABLE [dbo].[SocailShare_Forum_Messages]

/****** Object:  Table [dbo].[SocailShare_Site_Contents]    Script Date: 06/16/2011 13:48:43 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[SocailShare_Site_Contents]') AND type in (N'U'))
DROP TABLE [dbo].[SocailShare_Site_Contents]

/****** Object:  Table [dbo].[SocialShare_Admin_Users]    Script Date: 06/16/2011 13:48:43 ******/
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Admin_Users_Date_Created]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[SocialShare_Admin_Users] DROP CONSTRAINT [DF_Admin_Users_Date_Created]
END

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[SocialShare_Admin_Users]') AND type in (N'U'))
DROP TABLE [dbo].[SocialShare_Admin_Users]

/****** Object:  Table [dbo].[SocialShare_Blogs]    Script Date: 06/16/2011 13:48:43 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[SocialShare_Blogs]') AND type in (N'U'))
DROP TABLE [dbo].[SocialShare_Blogs]

/****** Object:  Table [dbo].[SocialShare_Forum_Categories]    Script Date: 06/16/2011 13:48:43 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[SocialShare_Forum_Categories]') AND type in (N'U'))
DROP TABLE [dbo].[SocialShare_Forum_Categories]

/****** Object:  Table [dbo].[SocialShare_MemberProfiles]    Script Date: 06/16/2011 13:48:43 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[SocialShare_MemberProfiles]') AND type in (N'U'))
DROP TABLE [dbo].[SocialShare_MemberProfiles]

/****** Object:  Table [dbo].[SocialShare_Members]    Script Date: 06/16/2011 13:48:43 ******/
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Members_Date_Started]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[SocialShare_Members] DROP CONSTRAINT [DF_Members_Date_Started]
END

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[SocialShare_Members]') AND type in (N'U'))
DROP TABLE [dbo].[SocialShare_Members]

/****** Object:  Table [dbo].[SocialShare_Members]    Script Date: 06/16/2011 13:48:43 ******/
SET ANSI_NULLS ON

SET QUOTED_IDENTIFIER ON

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[SocialShare_Members]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[SocialShare_Members](
	[Member_Id] [int] IDENTITY(1,1) NOT NULL,
	[ScreenName] [nvarchar](50) NULL,
	[Password] [nvarchar](50) NULL,
	[Email] [nvarchar](50) NULL,
	[CreateDate] [datetime] NULL CONSTRAINT [DF_Members_Date_Started]  DEFAULT (getdate()),
	[AccountStatus] [int] NULL,
	[AuthCode] [nvarchar](50) NULL,
 CONSTRAINT [PK_Table_1] PRIMARY KEY CLUSTERED 
(
	[Member_Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END

/****** Object:  Table [dbo].[SocialShare_MemberProfiles]    Script Date: 06/16/2011 13:48:43 ******/
SET ANSI_NULLS ON

SET QUOTED_IDENTIFIER ON

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[SocialShare_MemberProfiles]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[SocialShare_MemberProfiles](
	[ProfileId] [int] IDENTITY(1,1) NOT NULL,
	[UserId] [nvarchar](50) NULL,
	[BlogName] [nvarchar](50) NULL,
	[First_Name] [nvarchar](50) NULL,
	[Last_Name] [nvarchar](50) NULL,
	[DOB] [datetime] NULL,
	[Website] [nvarchar](max) NULL,
	[Sex] [nvarchar](50) NULL,
 CONSTRAINT [PK_SocialShare_MemberProfiles] PRIMARY KEY CLUSTERED 
(
	[ProfileId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END

/****** Object:  Table [dbo].[SocialShare_Forum_Categories]    Script Date: 06/16/2011 13:48:43 ******/
SET ANSI_NULLS ON

SET QUOTED_IDENTIFIER ON

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[SocialShare_Forum_Categories]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[SocialShare_Forum_Categories](
	[CategoryId] [int] IDENTITY(1,1) NOT NULL,
	[CategoryName] [nvarchar](500) NULL,
	[CategoryPic] [nvarchar](max) NULL,
	[DateCreated] [datetime] NULL,
	[Status] [int] NULL,
 CONSTRAINT [PK_Forum_Categories] PRIMARY KEY CLUSTERED 
(
	[CategoryId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END

/****** Object:  Table [dbo].[SocialShare_Blogs]    Script Date: 06/16/2011 13:48:43 ******/
SET ANSI_NULLS ON

SET QUOTED_IDENTIFIER ON

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[SocialShare_Blogs]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[SocialShare_Blogs](
	[BlogId] [int] IDENTITY(1,1) NOT NULL,
	[PostTitle] [nvarchar](500) NULL,
	[PostSummary] [nvarchar](500) NULL,
	[PostContent] [nvarchar](max) NULL,
	[DateCreated] [datetime] NULL,
	[UserId] [nvarchar](50) NULL,
	[IsCommentsAllowed] [bit] NULL,
	[PostStatus] [int] NULL,
	[Tags] [nvarchar](500) NULL,
 CONSTRAINT [PK_SocialShare_Blogs] PRIMARY KEY CLUSTERED 
(
	[BlogId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END

/****** Object:  Table [dbo].[SocialShare_Admin_Users]    Script Date: 06/16/2011 13:48:43 ******/
SET ANSI_NULLS ON

SET QUOTED_IDENTIFIER ON

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[SocialShare_Admin_Users]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[SocialShare_Admin_Users](
	[Admin_User_Id] [int] IDENTITY(1,1) NOT NULL,
	[User_Name] [nvarchar](50) NOT NULL,
	[Password] [nvarchar](50) NOT NULL,
	[Date_Created] [datetime] NULL CONSTRAINT [DF_Admin_Users_Date_Created]  DEFAULT (getdate()),
 CONSTRAINT [PK_Admin_Users] PRIMARY KEY CLUSTERED 
(
	[Admin_User_Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END

/****** Object:  Table [dbo].[SocailShare_Site_Contents]    Script Date: 06/16/2011 13:48:43 ******/
SET ANSI_NULLS ON

SET QUOTED_IDENTIFIER ON

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[SocailShare_Site_Contents]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[SocailShare_Site_Contents](
	[CmsId] [int] IDENTITY(1,1) NOT NULL,
	[CmsType] [nvarchar](50) NULL,
	[CmsTitle] [nvarchar](100) NULL,
	[CmsContent] [nvarchar](max) NULL,
	[IsActive] [bit] NULL,
 CONSTRAINT [PK_Site_Contents] PRIMARY KEY CLUSTERED 
(
	[CmsId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END

/****** Object:  Table [dbo].[SocailShare_Forum_Messages]    Script Date: 06/16/2011 13:48:43 ******/
SET ANSI_NULLS ON

SET QUOTED_IDENTIFIER ON

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[SocailShare_Forum_Messages]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[SocailShare_Forum_Messages](
	[PostId] [int] IDENTITY(1,1) NOT NULL,
	[CategoryId] [int] NULL,
	[ParentPostId] [int] NULL,
	[UserId] [nvarchar](max) NOT NULL,
	[MessageSubject] [nvarchar](max) NOT NULL,
	[MessageBody] [nvarchar](max) NOT NULL,
	[Status] [int] NOT NULL,
	[CreateDate] [datetime] NOT NULL,
	[IsAdminNotice] [int] NULL,
 CONSTRAINT [PK_Forum_Message] PRIMARY KEY CLUSTERED 
(
	[PostId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END

/****** Object:  Table [dbo].[SocialShare_Blog_Comments]    Script Date: 06/16/2011 13:48:43 ******/
SET ANSI_NULLS ON

SET QUOTED_IDENTIFIER ON

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[SocialShare_Blog_Comments]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[SocialShare_Blog_Comments](
	[CommentsId] [int] IDENTITY(1,1) NOT NULL,
	[UserId] [nvarchar](50) NULL,
	[BlogId] [int] NOT NULL,
	[UserEmail] [nvarchar](500) NULL,
	[UserName] [nvarchar](500) NULL,
	[Comments] [nvarchar](1000) NOT NULL,
	[CreateDate] [datetime] NULL,
	[IsActive] [bit] NULL,
 CONSTRAINT [PK_SocialShare_Blog_Comments] PRIMARY KEY CLUSTERED 
(
	[CommentsId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END

/****** Object:  ForeignKey [FK_Forum_Messages_Forum_Categories]    Script Date: 06/16/2011 13:48:43 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Forum_Messages_Forum_Categories]') AND parent_object_id = OBJECT_ID(N'[dbo].[SocailShare_Forum_Messages]'))
ALTER TABLE [dbo].[SocailShare_Forum_Messages]  WITH CHECK ADD  CONSTRAINT [FK_Forum_Messages_Forum_Categories] FOREIGN KEY([CategoryId])
REFERENCES [dbo].[SocialShare_Forum_Categories] ([CategoryId])
ON UPDATE CASCADE
ON DELETE CASCADE

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Forum_Messages_Forum_Categories]') AND parent_object_id = OBJECT_ID(N'[dbo].[SocailShare_Forum_Messages]'))
ALTER TABLE [dbo].[SocailShare_Forum_Messages] CHECK CONSTRAINT [FK_Forum_Messages_Forum_Categories]

/****** Object:  ForeignKey [FK_SocialShare_Blog_Comments_SocialShare_Blogs]    Script Date: 06/16/2011 13:48:43 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_SocialShare_Blog_Comments_SocialShare_Blogs]') AND parent_object_id = OBJECT_ID(N'[dbo].[SocialShare_Blog_Comments]'))
ALTER TABLE [dbo].[SocialShare_Blog_Comments]  WITH CHECK ADD  CONSTRAINT [FK_SocialShare_Blog_Comments_SocialShare_Blogs] FOREIGN KEY([BlogId])
REFERENCES [dbo].[SocialShare_Blogs] ([BlogId])
ON UPDATE CASCADE
ON DELETE CASCADE

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_SocialShare_Blog_Comments_SocialShare_Blogs]') AND parent_object_id = OBJECT_ID(N'[dbo].[SocialShare_Blog_Comments]'))
ALTER TABLE [dbo].[SocialShare_Blog_Comments] CHECK CONSTRAINT [FK_SocialShare_Blog_Comments_SocialShare_Blogs]

